{extend name="Dashboard/dashboard" /}

{block name="content"}
			<div style="padding-top: 30px"></div>
	<form class="form-horizontal" method="post" action="<{:url('User/insert')}>" name="regForm" onsubmit="return checkForm()">
		<div class="form-group">
		    <label for="inputEmail3" class="col-sm-2 control-label">昵称</label>
		    <div class="col-sm-5" style="display: inline-block;">
		      <input type="text" class="form-control" id="inputEmail3" onblur="checkUser()" name="nickname" placeholder="昵称">
			</div>
			<span for="inputEmail3" class="col-sm-5 control-label" style="text-align: left" id="utab">* 必填项,请输入昵称(2-15位,数字字母下划线且必须由字母中文开头)</span>
		</div>
	  	<div class="form-group">
		    <label for="inputEmail3" class="col-sm-2 control-label">邮箱</label>
		    <div class="col-sm-5" style="display: inline-block;">
		      <input type="email" class="form-control" id="inputEmail3" onblur="checkEmail()" name="email" placeholder="邮箱">
			</div>
			<span for="inputEmail3" class="col-sm-5 control-label" style="text-align: left" id="etab">* 必填项,请输入常用邮箱</span>
		</div>
		<div class="form-group">
		    <label for="inputEmail3" class="col-sm-2 control-label">电话</label>
		    <div class="col-sm-5" style="display: inline-block;">
		      <input type="text" class="form-control" id="inputEmail3" onblur="checkPhone()" name="tel" placeholder="电话"  maxlength="11">
			</div>
			<span for="inputEmail3" class="col-sm-5 control-label" style="text-align: left" id="teltab">* 必填项,请输入常用手机号码</span>
		</div>
	  	<div class="form-group">
		    <label for="inputPassword3" class="col-sm-2 control-label">密码</label>
		    <div class="col-sm-5" style="display: inline-block;">
		      <input type="password" class="form-control" id="inputPassword3" onblur="checkPass()" name="pwd" placeholder="密码" autocomplete="off">
		    </div>
		    <span for="inputEmail3" class="col-sm-5 control-label" style="text-align: left" autocomplete="off" id="ptab">* 必填项,请输入6-12位密码</span>
	  	</div>
	  	<div class="form-group">
		    <label for="inputPassword3" class="col-sm-2 control-label">确认密码</label>
		    <div class="col-sm-5" style="display: inline-block;">
		      <input type="password" class="form-control" id="inputPassword3" onblur="checkRepass()" name="repwd" placeholder="确认密码">
		    </div>
		     <span for="inputEmail3" class="col-sm-5 control-label" style="text-align: left" id="rptab">* 必填项,请在输入一次</span>
	  	</div>
		
		<div class="form-group">
		    <div class="col-sm-offset-2 col-sm-10">
		      <button type="submit" class="btn btn-default">确认添加</button>
		    </div>
		</div>
	</form>

	<!-- 表单失焦验证 -->
	<script>
		//邮箱
        function checkEmail(){
            var email = document.regForm.email.value;
            var etab = document.getElementById('etab');

            if (email.match(/^[\w-]+@[\w-]+(\.\w+){1,3}$/) == null) {
                etab.innerHTML = "* 邮箱格式不正确";
                etab.style.color = "#f00";
                return false;
            }else{
                etab.innerHTML = "* 通过验证!";
                etab.style.color = "#0a0";
                return true;
            }
        }
         //用户
        function checkUser(){
            var user = document.regForm.nickname.value;
            var utab = document.getElementById('utab');

            if (user.match(/^[a-zA-Z\u4e00-\u9fa5][a-zA-Z0-9_\u4E00-\u9FA5]{1,15}$/) == null) {
                utab.innerHTML = "* 用户名必须是: 2-15位,数字字母下划线且必须由字母中文开头";
                utab.style.color = "#f00";
                return false;
            }else{
                utab.innerHTML = "* 通过验证!";
                utab.style.color = "#0a0";
                return true;
            }
        }
        //手机
        function checkPhone(){
            var phone = document.regForm.tel.value;
            var teltab = document.getElementById('teltab');

  

            if (phone.match(/^1(3|4|5|7|8)\d{9}$/) == null) {
                teltab.innerHTML = "* 手机号必须是: 11位纯数字且合法";
                teltab.style.color = "#f00";
                return false;
            }else{
                teltab.innerHTML = "* 通过验证!";
                teltab.style.color = "#0a0";
                return true;
            }
        }
        //密码
        function checkPass(){
            var pass = document.regForm.pwd.value;
            var ptab = document.getElementById('ptab');

            if (pass.length < 6 || pass.length > 18 ) {
                ptab.innerHTML = "* 密码不合法,必须是6-18位";
                ptab.style.color = "#f00";
                return false;
            }else{
                ptab.innerHTML = "* 通过验证!";
                ptab.style.color = "#0a0";
                return true;
            }
        }

        //密码
        function checkRepass(){
            var pass = document.regForm.pwd.value;
            var repass = document.regForm.repwd.value;
            var rptab = document.getElementById('rptab');

            if (pass !== repass) {
                rptab.innerHTML = "* 两次密码不一致";
                rptab.style.color = "#f00";
                return false;
            }else{
                rptab.innerHTML = "* 通过验证!";
                rptab.style.color = "#0a0";
                return true;
            }
        }

        function checkForm(){
            return checkEmail() && checkUser() && checkPass() && checkRepass() && checkPhone();
        }
	</script>
{/block}